﻿using System;
using System.Collections.Generic;
using System.Text;

using Newtonsoft.Json;

namespace Utils.Converters
{
    public class SerializerConverter : JsonConverter
    {
        private readonly JsonSerializer jsonSerializer = JsonSerializer.CreateDefault();
        public override bool CanConvert(Type objectType)
        {
            return true;
        }

        public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
        {
            return jsonSerializer.Deserialize(reader, objectType);
        }

        public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
        {
            jsonSerializer.Serialize(writer, value);
        }
    }
}
